home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume11 / graphedit / part01 next >
Encoding:
Internet Message Format  |  1987-10-05  |  47.9 KB

  1. Subject:  v11i097:  Graphcs editor for Suns, Part01/06
  2. Newsgroups: comp.sources.unix
  3. Sender: sources
  4. Approved: rs@uunet.UU.NET
  5.  
  6. Submitted-by: steinmetz!sbcs!nyfca1!chan (Douglas Chan)
  7. Posting-number: Volume 11, Issue 97
  8. Archive-name: graphedit/part01
  9.  
  10.   This is the first release of a graphic editor implemented for Suns
  11. running Sun 3.2 or latter.  Some minor changes are necessary to run it on
  12. Sun 3.0 (mostly on the device dependent part, eg. anything related
  13. to cg4dd()) and I did not do it because there is no Sun running 3.0 here.
  14.  
  15. Features of the current program include:
  16.   1) display and edit of diagram with SunCore
  17.   2) select operations and options on control pad in SunView
  18.   3) save/load of diagram in PostScript
  19.   4) output of diagram in rasterfile(5), plot(5) and pic(1) format
  20.   5) draw lines, polygon, circle, ellipse, arc, rectangle, text
  21.      and freehand
  22.   6) operations on 'segments' include create, edit, save, load, copy,
  23.      move, rotate, scale, join, break, delete and undelete
  24.   7) can specify line width, linestyle, font, character size, and greylevel
  25.   8) grid and alignment
  26.   9) options to specify how to place diagram on 8.5 x 11 paper (PostScript only)
  27.  10) global scale of diagram
  28.  
  29.   More information is in README and graphedit.l (manual page).
  30.  
  31.   Have fun!!!
  32.  
  33. Douglas Chan.
  34.  
  35. Address: Computer Science Department
  36.          State University of New York at Stony Brook
  37.          Stony Brook, NY 11794
  38.  
  39. csnet address: chan@sbcs.csnet
  40. uucp address: {allegra,philabs,pyramid}!sbcs!chan
  41.  
  42. ---------Cut Here--------Cut Here--------Cut Here--------Cut Here--------
  43. # This is a shell archive.  Remove anything before this line,
  44. # then unpack it by saving it in a file and typing "sh file".
  45. #
  46. # Contents:  README Makefile display.h panel.c savepanel.c
  47.  
  48. echo x - README
  49. sed 's/^@//' > "README" <<'@//E*O*F README//'
  50.  
  51.   @(#)README    1.1 6/8/87 Copyright 1987 SBCS-chan
  52.  
  53. ******************************************************************************
  54.  
  55.           (c) Copyright 1987 
  56.  
  57.           Lap-Tak Chan
  58.           Computer Science Department
  59.           State University of New York at Stony Brook
  60.           Stony Brook, NY 11794
  61.  
  62.     This software and its documentation may be used, copied, and
  63.   distributed, provided that this legend appear in all copies and
  64.   that it is not copied or distributed for a profit.
  65.  
  66.   No representations is made about the suitability of this software
  67.   for any purpose.  It is provided "as is" with no support and no
  68.   express or implied warranty.
  69.  
  70. ******************************************************************************
  71.  
  72.   graphedit is a general purpose graphic editor for Sun workstations.
  73. It was implemented on Sun-3s running Sun release 3.2 with SunView
  74. and SunCore.  Some changes on core.c are necessary to run it on
  75. Sun 3.0.
  76.  
  77.   Features of the current version of graphedit include:
  78.  
  79.   1) display and edit of diagram with SunCore
  80.   2) select operations and options on control pad in SunView
  81.   3) save/load of diagram in PostScript
  82.   4) output of diagram in rasterfile(5), plot(5) and pic(1) format
  83.   5) draw lines, polygon, circle, ellipse, arc, rectangle, text
  84.      and freehand
  85.   6) operations on 'segments' include create, edit, save, load, copy,
  86.      move, rotate, scale, join, break, delete and undelete
  87.   7) can specify line width, linestyle, font, character size, and greylevel
  88.   8) grid and alignment
  89.   9) options to specify how to place diagram on 8.5 x 11 paper (PostScript only)
  90.  10) global scale of diagram
  91.  11) usage and message panel to display messages and "how-to"s
  92.  12) many other options
  93.  
  94.   Files in this directory include:
  95. README                you are reading it
  96. display.h             include file used by all c files
  97. draw.c                editing routines
  98. core.c                SunCore interface
  99. display.c             maintain display list for storage of diagram
  100. panel.c               create control pad
  101. savepanel.c           create options window
  102. misc.c                some math routines
  103. optmize.c             internal optimizer
  104. ps.c                  save/load diagram/segment in PostScript
  105. pic.c                 output diagram for pic(1)
  106. plot.c                output diagram in plot(5)
  107. optm.c                driver for internal optimizer
  108. ps2pic.c              driver to convert saved diagram to pic(1)
  109. ps2plot.c             driver to convert saved diagram to plot(1)
  110. images                directory for icon and images created by iconedit(1)
  111. Makefile              makefile for graphedit
  112. ps.head               header file for saved diagram (in PostScript)
  113. graphedit.l           manual page
  114.  
  115.   To install it, set the parameters at the beginning of Makefile and do
  116.     make install
  117. More information on the installation is available in Makefile.
  118.  
  119.   You may modify the source to fix bugs and port it for any new Sun
  120. hardware (e.g. cgfive0).  Please send any fixes to me at chan@sbcs.csnet
  121. or {allegra,philabs,pyramid}!sbcs!chan so I can add them to future
  122. releases.
  123.  
  124.   There is ongoing effort to add more advance editing functions
  125. and primitives to graphedit, and to improve the existing
  126. functions.  Please do not modify the source for any enhancement
  127. to avoid duplicate efforts and any difficulty on combining
  128. the enhancement to future releases.  You are welcome to send
  129. suggestions to me at the email addresses above.
  130. @//E*O*F README//
  131. chmod u=r,g=r,o=r README
  132.  
  133. echo x - Makefile
  134. sed 's/^@//' > "Makefile" <<'@//E*O*F Makefile//'
  135. #
  136. # @(#)Makefile    1.2 6/8/87 Copyright 1987 SBCS-chan
  137. #******************************************************************************
  138. #
  139. #          (c) Copyright 1987 
  140. #
  141. #          Lap-Tak Chan
  142. #          Computer Science Department
  143. #          State University of New York at Stony Brook
  144. #          Stony Brook, NY 11794
  145. #
  146. #    This software and its documentation may be used, copied, and
  147. #  distributed, provided that this legend appear in all copies and
  148. #  that it is not copied or distributed for a profit.
  149. #
  150. #  No representations is made about the suitability of this software
  151. #  for any purpose.  It is provided "as is" with no support and no
  152. #  express or implied warranty.
  153. #
  154. #******************************************************************************
  155.  
  156. #
  157. #  To install graphedit, set the proper value of the following parameters
  158. #  and do 'make install':
  159. #    LIB - existing directory where the header file will be installed
  160. #    BIN - existing directory to install the binaries
  161. #    BINARIES - what binaries to make
  162. #    CFLAGS - C compiler options
  163. #    LFLAGS - libraries, 'core' may be changed to 'corefpa' or 'core68881'
  164. #             for different floating point options
  165. #
  166. #  ps2pic, optm, ps2plot are optional filters which take a saved PostScript
  167. #  diagram from standard input and produce pic output, optimized PostScript,
  168. #  and plot output on stardard output respectively.
  169. #
  170. #  graphedit.l should be installed manually because of differnet ways to
  171. #  handle local manual pages at different sites.
  172. #
  173. LIB=/usr/local/lib
  174.  
  175. BIN=/usr/local/bin
  176.  
  177. BINARIES=graphedit ps2pic optm ps2plot
  178.  
  179. CFLAGS=-DGE_DEFAULTLIB=\"$(LIB)\" -O -fswitch -s
  180.  
  181. LFLAGS=-lcore -lsuntool -lsunwindow -lpixrect -lplot -lm
  182.  
  183. OBJ=draw.o panel.o core.o display.o ps.o savepanel.o pic.o plot.o optmize.o misc.o
  184.  
  185. OPTMOBJ=optm.o ps.o display.o optmize.o
  186.  
  187. PS2PLOTOBJ=ps2plot.o plot.o ps.o display.o misc.o
  188.  
  189. PS2PICOBJ=ps2pic.o pic.o ps.o display.o misc.o
  190.  
  191. BACKUP=/u7/sr/chan/backup/newdraw
  192.  
  193. FILES=README Makefile display.h draw.c panel.c core.c display.c ps.c savepanel.c pic.c plot.c optmize.c misc.c ps2pic.c ps2plot.c optm.c images images/* ps.head graphedit.l
  194.  
  195. make: $(BINARIES)
  196.  
  197. graphedit: ${OBJ}
  198.     cc ${CFLAGS} -o graphedit ${OBJ} ${LFLAGS}
  199.  
  200. ps2pic: ${PS2PICOBJ}
  201.     cc ${CFLAGS} -o ps2pic ${PS2PICOBJ} -lm
  202.  
  203. optm: ${OPTMOBJ}
  204.     cc ${CFLAGS} -o optm ${OPTMOBJ}
  205.  
  206. ps2plot: ${PS2PLOTOBJ}
  207.     cc ${CFLAGS} -o ps2plot ${PS2PLOTOBJ} -lplot -lm
  208.  
  209. all: graphedit ps2pic optm ps2plot
  210.  
  211. install: ${BINARIES}
  212.     /bin/cp -p ${BINARIES} ${BIN}
  213.     /bin/cp -p ps.head ${LIB}
  214.  
  215. backup:
  216.     tar cf ${BACKUP} ${FILES} SCCS
  217.  
  218. shar:
  219.     ./makeshar
  220.  
  221. clean:
  222.     /bin/rm -f ${OBJ} ${OPTMOBJ} ${PS2PICOBJ} ${PS2PLOTOBJ} ${BINARIES}
  223. @//E*O*F Makefile//
  224. chmod u=rw,g=r,o=r Makefile
  225.  
  226. echo x - display.h
  227. sed 's/^@//' > "display.h" <<'@//E*O*F display.h//'
  228.  
  229. /* @(#)display.h    1.2    6/8/87 Copyright 1987 SBCS-chan */
  230.  
  231. /*****************************************************************************
  232.  
  233.           (c) Copyright 1987 
  234.  
  235.           Lap-Tak Chan
  236.           Computer Science Department
  237.           State University of New York at Stony Brook
  238.           Stony Brook, NY 11794
  239.  
  240.     This software and its documentation may be used, copied, and
  241.   distributed, provided that this legend appear in all copies and
  242.   that it is not copied or distributed for a profit.
  243.  
  244.   No representations is made about the suitability of this software
  245.   for any purpose.  It is provided "as is" with no support and no
  246.   express or implied warranty.
  247.  
  248. *****************************************************************************/
  249.  
  250. /*****************************************************************************
  251.  
  252.                              display.h
  253.  
  254.    This file defines the constants and structures for graphedit.
  255.  
  256. *****************************************************************************/
  257.  
  258. #define GE_VERSION "1.1" /* current version of graphedit */
  259.  
  260. /* display instructions */
  261. #define GE_MOVE    1    /* move */
  262. #define GE_LINE 2    /* line */
  263. #define GE_PLOT 3    /* move and intensify at end of stroke */
  264. #define GE_POLYLINE 4    /* polyline */
  265. #define GE_POLYGON 5    /* polygon */
  266. #define GE_TEXT 6    /* text */
  267. #define GE_ARC 7    /* arc */
  268. #define GE_CIRCLE 8    /* circle */
  269. #define GE_ELLIPSE 9    /* ellipse */
  270. #define GE_CONT 10    /* continue of point list of last polygon/polyline */
  271. #define GE_ARCEXT 11    /* extension for arc */
  272. #define GE_SETCOLOR 20    /* change color attribute */
  273. #define GE_SETTYPELINE 21    /* change line style */
  274. #define GE_SETLINEWIDTH 22    /* change line width */
  275. #define GE_SETFONT 23    /* change font */
  276. #define GE_TRANSLATE 24
  277. #define GE_ROTATE 25
  278. #define GE_SCALE 26
  279. #define GE_SETCHARSIZE 27 /* change character size */
  280. #define GE_FILL 28    /* border/fill */
  281. #define GE_NEW 31    /* beginning of new segment */
  282. #define GE_DELETE 32    /* delete old segment */
  283. #define GE_CLOSE 33    /* close a segment */
  284.  
  285. /* parameters for border/fill */
  286. #define GE_BORDERONLY 0
  287. #define GE_FILLONLY 1
  288. #define GE_FILLBORDER 2
  289.  
  290. #define MAXUNDELETE 10 /* maximum number of segments which can be undeleted */
  291.  
  292. #define GE_OPENMAX 512    /* maximum number of opened segemnts at any time */
  293.  
  294. /* sample segments */
  295. #define GE_COLOR_SAMPLE 1    /* show different color */
  296. #define GE_LINE_SAMPLE 2    /* show different linewidth and linestyle */
  297. #define GE_CHAR_SAMPLE 3    /* show different character size and font */
  298. #define GE_GRID 4    /* grid */
  299. #define GE_CIRCLE_SAMPLE 5    /* used to draw ellipse/circle */
  300. #define GE_CROSSHAIR 6    /* echo at location read */
  301. #define GE_ARC_SAMPLE 7    /* used to draw arc */
  302. #define GE_MIN_SEG 10    /* lowest segment number available to user */
  303.  
  304. /* define size of window in world coordinate */
  305. #define GE_WIN_X 511.
  306. #define GE_WIN_Y 383.
  307.  
  308. #define GE_DEFAULT_GRID 10.
  309. #define GE_MIN_GRID 5.
  310. #define GE_DEFAULT_CHARSIZE 8
  311. #define GE_DEFAULT_RADIUS 10.
  312. #define PI 3.1415927
  313.  
  314. /* define how picture will be positioned on 8.5 x 11 paper */
  315. struct saveattr {
  316.   int fix;    /* 0 - Scale, 1 - Fix Width, 2 - Fix Height */
  317.   int rotate;    /* whether picture is rotated 90 degree */
  318.   int width;    /* width of picture, independent to rotate */
  319.   int height;    /* height of picture, independent to rotate */
  320.   int center;    /* whether picture is centered on paper */
  321.   int offa;    /* horizontal offset */
  322.   int offb;    /* vertical offset */
  323. };
  324.  
  325. /* define attributes of a segment */
  326. struct attr {
  327.   float tx, ty;    /* translation in world coordinate */
  328.   float ang;    /* angle of rotation in radian */
  329.   float sx, sy;    /* scaling factor */
  330.   int color;    /* color in 0-11 from light to dark*/
  331.   int linestyle;/* line style, 0 - solid, 1 - dotted, 2 - dashed, 3 - dotdash */
  332.   int linewidth;/* line width */
  333.   int font;    /* font, 0 - Courier, 1 - Roman, 2- Greek, 3 - BoldItalic,
  334.                    4 - Bold */
  335.   int charsize;    /* character size */
  336.   int drawn;    /* whether segment was drawn by ge_draw */
  337.   int deleted;    /* whether segment was marked as deleted */
  338. };
  339.  
  340. /* a display item */
  341. struct list_item {
  342.   int instr;  /* display instruction (move, plot, line, etc) */
  343.   float x,y;  /* display coordinate (or other parameters) */
  344.   struct list_item *next; /* point to next display item */
  345. };
  346.  
  347. /* display list of a segment */
  348. struct list {
  349.   int segno; /* segment number */
  350.   struct list_item *d_list; /* list of display items */
  351.   int next; /* point to next segment */
  352.   struct attr attr; /* attributes of segment */
  353. };
  354. @//E*O*F display.h//
  355. chmod u=r,g=r,o=r display.h
  356.  
  357. echo x - panel.c
  358. sed 's/^@//' > "panel.c" <<'@//E*O*F panel.c//'
  359.  
  360. static char SccsId[] = "@(#)panel.c    1.2 6/8/87 Copyright 1987 SBCS-chan";
  361.  
  362. /*****************************************************************************
  363.  
  364.           (c) Copyright 1987 
  365.  
  366.           Lap-Tak Chan
  367.           Computer Science Department
  368.           State University of New York at Stony Brook
  369.           Stony Brook, NY 11794
  370.  
  371.     This software and its documentation may be used, copied, and
  372.   distributed, provided that this legend appear in all copies and
  373.   that it is not copied or distributed for a profit.
  374.  
  375.   No representations is made about the suitability of this software
  376.   for any purpose.  It is provided "as is" with no support and no
  377.   express or implied warranty.
  378.  
  379. *****************************************************************************/
  380.  
  381. /*****************************************************************************
  382.  
  383.                           Control Pad
  384.                           ===========
  385.  
  386.     This file contains routines for making and maintaining the control
  387.   pad of graphedit.
  388.  
  389. *****************************************************************************/
  390.  
  391. #include <suntool/sunview.h>
  392. #include <suntool/panel.h>
  393. #include "display.h"
  394.  
  395. /* external notify procedures for panel items in the control pad */
  396. extern void do_new_seg(), do_del_seg(),
  397.               do_align(), do_grid(),
  398.               do_polyline(),do_circle(),do_rect(),
  399.               do_polygon(), do_text(), do_pos(),
  400.               do_rot(), do_size(), do_attributes(), do_save_seg(),
  401.               do_restore_seg(), do_exit(), do_save_pic(), do_restore_pic(),
  402.               do_change_color(), do_change_linewidth(), do_change_linestyle(),
  403.               do_chg_xformchar(), do_change_font(), ge_refresh(), do_undelete(),
  404.               do_confirm_exit(), do_copy_segment(), do_break(), do_arc(),
  405.               do_change_grid(), do_edit_seg(), do_change_charsize(),
  406.               do_join(), do_clear(), do_trace(), do_ellipse(), do_output(),
  407.               do_global_scale();
  408.  
  409. void do_show_save();
  410.  
  411. /* exported panel items for draw.c */
  412. Panel_item text_filen, text_textstr, mesg_display, mesg_usage;
  413. Panel_item slider_linewidth, menu_linestyle, menu_font, slider_color,
  414.            cycle_grid, cycle_align, cycle_fill,
  415.            slider_gridx, slider_gridy, slider_charsize, cycle_save;
  416.  
  417. /* define pixrect images for the panel items */
  418.   static short polyline_pr_image[]={
  419. #include "images/polyline.pr"
  420.   };
  421.  
  422.   static short polygon_pr_image[]={
  423. #include "images/polygon.pr"
  424.   };
  425.  
  426.   static short circle_pr_image[]={
  427. #include "images/circle.pr"
  428.   };
  429.  
  430.   static short rect_pr_image[]={
  431. #include "images/rect.pr"
  432.   };
  433.  
  434.   static short trace_pr_image[]={
  435. #include "images/trace.pr"
  436.   };
  437.  
  438.   static short ellipse_pr_image[]={
  439. #include "images/ellipse.pr"
  440.   };
  441.  
  442.   static short arc_pr_image[]={
  443. #include "images/arc.pr"
  444.   };
  445.  
  446.   static short text_pr_image[]={
  447. #include "images/text.pr"
  448.   };
  449.  
  450.   static short border_pr_image[]={
  451. #include "images/border.pr"
  452.   };
  453.  
  454.   static short fill_pr_image[]={
  455. #include "images/fill.pr"
  456.   };
  457.  
  458.   static short borderfill_pr_image[]={
  459. #include "images/borderfill.pr"
  460.   };
  461.  
  462.   static short solid_pr_image[]={
  463. #include "images/solid.pr"
  464.   };
  465.  
  466.   static short dot_pr_image[]={
  467. #include "images/dot.pr"
  468.   };
  469.  
  470.   static short dash_pr_image[]={
  471. #include "images/dash.pr"
  472.   };
  473.  
  474.   static short dotdash_pr_image[]={
  475. #include "images/dotdash.pr"
  476.   };
  477.  
  478.   mpr_static(polyline_pr, 16, 16, 1, polyline_pr_image);
  479.   mpr_static(polygon_pr, 16, 16, 1, polygon_pr_image);
  480.   mpr_static(circle_pr, 16, 16, 1, circle_pr_image);
  481.   mpr_static(rect_pr, 16, 16, 1, rect_pr_image);
  482.   mpr_static(trace_pr, 16, 16, 1, trace_pr_image);
  483.   mpr_static(ellipse_pr, 16, 16, 1, ellipse_pr_image);
  484.   mpr_static(arc_pr, 16, 16, 1, arc_pr_image);
  485.   mpr_static(text_pr, 16, 16, 1, text_pr_image);
  486.   mpr_static(border_pr, 64, 14, 1, border_pr_image);
  487.   mpr_static(fill_pr, 64, 14, 1, fill_pr_image);
  488.   mpr_static(borderfill_pr, 64, 14, 1, borderfill_pr_image);
  489.   mpr_static(solid_pr, 64, 14, 1, solid_pr_image);
  490.   mpr_static(dot_pr, 64, 14, 1, dot_pr_image);
  491.   mpr_static(dash_pr, 64, 14, 1, dash_pr_image);
  492.   mpr_static(dotdash_pr, 64, 14, 1, dotdash_pr_image);
  493.  
  494. /*****************************************************************************
  495.  
  496.     make_control_panel will create the message panel, main panel, segment
  497.   panel, primitive panel and attribute panel in frame.  Each panel will
  498.   have a number of panel items in it.
  499.  
  500.   Input
  501.     frame - the frame to create the panels in
  502.  
  503. *****************************************************************************/
  504.  
  505. make_control_panel(frame)
  506. Frame frame;
  507. {
  508.   Panel panels[5];
  509. #define mesg_panel panels[0]
  510. #define main_panel panels[1]
  511. #define seg_panel  panels[2]
  512. #define draw_panel panels[3]
  513. #define attr_panel panels[4]
  514.  
  515.   /* panel items known internally */
  516.   Panel_item but_new_seg, but_del_seg, but_clear,
  517.              but_polyline, but_polygon, but_circle, but_rect,
  518.              but_text, but_pos, but_rot, but_size, but_join, but_undelete,
  519.              but_attributes, but_save_seg, but_restore_seg, but_edit_seg,
  520.              but_exit, but_save_pic, but_restore_pic, but_redisplay,
  521.              but_copy_seg, cycle_grid, cycle_align, but_break, but_trace,
  522.              but_ellipse, but_output, but_arc, but_glbscale;
  523.  
  524.   /* create the message panel */
  525.   mesg_panel=window_create(frame, PANEL, 0);
  526.  
  527.   /* item for the message */
  528.   mesg_display=panel_create_item(mesg_panel, PANEL_MESSAGE,
  529.                PANEL_LABEL_STRING, " ",
  530.                PANEL_LABEL_BOLD, TRUE,               
  531.                PANEL_ITEM_Y, ATTR_ROW(0),
  532.                0);
  533.  
  534.   /* item for the usage */
  535.   mesg_usage=panel_create_item(mesg_panel, PANEL_MESSAGE,
  536.                PANEL_LABEL_STRING, " ",
  537.                PANEL_ITEM_X, ATTR_COL(0),
  538.                PANEL_ITEM_Y, ATTR_ROW(1),
  539.                0);
  540.  
  541.   window_fit(mesg_panel);
  542.  
  543.   /* create the main panel */
  544.   main_panel=window_create(frame, PANEL,
  545.                WIN_BELOW, mesg_panel,
  546.                WIN_X, ATTR_COLS(0),
  547.                0);
  548.  
  549.   /* save button */
  550.   but_save_pic=panel_create_item(main_panel, PANEL_BUTTON,
  551.                PANEL_LABEL_IMAGE, panel_button_image(main_panel,
  552.                "Save",
  553.                4,0),
  554.                PANEL_ITEM_X, ATTR_COL(0),
  555.                PANEL_ITEM_Y, ATTR_ROW(0),
  556.                PANEL_NOTIFY_PROC, do_save_pic,
  557.                0);
  558.  
  559.   /* load button */
  560.   but_restore_pic=panel_create_item(main_panel, PANEL_BUTTON,
  561.                PANEL_LABEL_IMAGE, panel_button_image(main_panel,
  562.                "Load",
  563.                4,0),
  564.                PANEL_ITEM_X, ATTR_COL(6),
  565.                PANEL_ITEM_Y, ATTR_ROW(0),
  566.                PANEL_NOTIFY_PROC, do_restore_pic,
  567.                0);
  568.  
  569.   /* redisplay button */
  570.   but_redisplay=panel_create_item(main_panel, PANEL_BUTTON,
  571.                PANEL_LABEL_IMAGE, panel_button_image(main_panel,
  572.            "Redisplay",
  573.                9,0),
  574.                PANEL_ITEM_X, ATTR_COL(12),
  575.                PANEL_ITEM_Y, ATTR_ROW(0),
  576.                PANEL_NOTIFY_PROC, ge_refresh,
  577.                0);
  578.  
  579.   /* quit button */
  580.   but_exit=panel_create_item(main_panel, PANEL_BUTTON,
  581.                PANEL_LABEL_IMAGE, panel_button_image(main_panel,
  582.                "Quit",
  583.                4,0),
  584.                PANEL_ITEM_X, ATTR_COL(23),
  585.                PANEL_ITEM_Y, ATTR_ROW(0),
  586.                PANEL_NOTIFY_PROC, do_confirm_exit,
  587.                0);
  588.  
  589.   /* clear button */
  590.   but_clear=panel_create_item(main_panel, PANEL_BUTTON,
  591.                PANEL_LABEL_IMAGE, panel_button_image(main_panel,
  592.                "Clear",
  593.                5,0),
  594.                PANEL_ITEM_X, ATTR_COL(29),
  595.                PANEL_ITEM_Y, ATTR_ROW(0),
  596.                PANEL_NOTIFY_PROC, do_clear,
  597.                0);
  598.  
  599.   /* scale button */
  600.   but_glbscale=panel_create_item(main_panel, PANEL_BUTTON,
  601.                PANEL_LABEL_IMAGE, panel_button_image(main_panel,
  602.                "Scale",
  603.                5,0),
  604.                PANEL_ITEM_X, ATTR_COL(36),
  605.                PANEL_ITEM_Y, ATTR_ROW(0),
  606.                PANEL_NOTIFY_PROC, do_global_scale,
  607.                0);
  608.  
  609.   /* output button */
  610.   but_output=panel_create_item(main_panel, PANEL_BUTTON,
  611.                PANEL_LABEL_IMAGE, panel_button_image(main_panel,
  612.                "Output",
  613.                6,0),
  614.                PANEL_ITEM_X, ATTR_COL(0),
  615.                PANEL_ITEM_Y, ATTR_ROW(1),
  616.                PANEL_NOTIFY_PROC, do_output,
  617.                0);
  618.  
  619.   /* file name field */
  620.   text_filen=panel_create_item(main_panel, PANEL_TEXT,
  621.                PANEL_LABEL_STRING, "File:",
  622.                PANEL_VALUE_DISPLAY_LENGTH, 30,
  623.                PANEL_ITEM_X, ATTR_COL(8),
  624.                PANEL_ITEM_Y, ATTR_ROW(1),
  625.                0);
  626.  
  627.   window_fit(main_panel);
  628.  
  629.   /* create the segment panel */
  630.   seg_panel=window_create(frame, PANEL,
  631.                WIN_BELOW, main_panel,
  632.                WIN_X, ATTR_COLS(0),
  633.                0);
  634.  
  635.   /* create button */
  636.   but_new_seg=panel_create_item(seg_panel, PANEL_BUTTON,
  637.                PANEL_LABEL_IMAGE, panel_button_image(seg_panel,
  638.                "Create",
  639.                6,0),
  640.                PANEL_NOTIFY_PROC, do_new_seg,
  641.                PANEL_ITEM_X, ATTR_COL(0),
  642.                PANEL_ITEM_Y, ATTR_ROW(0),
  643.                0);
  644.  
  645.   /* edit button */
  646.   but_edit_seg=panel_create_item(seg_panel, PANEL_BUTTON,
  647.                PANEL_LABEL_IMAGE, panel_button_image(seg_panel,
  648.                "Edit",
  649.                4,0),
  650.                PANEL_ITEM_X, ATTR_COL(8),
  651.                PANEL_ITEM_Y, ATTR_ROW(0),
  652.                PANEL_NOTIFY_PROC, do_edit_seg,
  653.                0);
  654.  
  655.   /* delete button */
  656.   but_del_seg=panel_create_item(seg_panel, PANEL_BUTTON,
  657.                PANEL_LABEL_IMAGE, panel_button_image(seg_panel,
  658.                "Delete",
  659.                6,0),
  660.                PANEL_ITEM_X, ATTR_COL(14),
  661.                PANEL_ITEM_Y, ATTR_ROW(0),
  662.                PANEL_NOTIFY_PROC, do_del_seg,
  663.                0);
  664.  
  665.   /* save button */
  666.   but_save_seg=panel_create_item(seg_panel, PANEL_BUTTON,
  667.                PANEL_LABEL_IMAGE, panel_button_image(seg_panel,
  668.                "Save",
  669.                4,0),
  670.                PANEL_ITEM_X, ATTR_COL(22),
  671.                PANEL_ITEM_Y, ATTR_ROW(0),
  672.                PANEL_NOTIFY_PROC, do_save_seg,
  673.                0);
  674.  
  675.   /* load button */
  676.   but_restore_seg=panel_create_item(seg_panel, PANEL_BUTTON,
  677.                PANEL_LABEL_IMAGE, panel_button_image(seg_panel,
  678.                "Load",
  679.                4,0),
  680.                PANEL_ITEM_X, ATTR_COL(28),
  681.                PANEL_ITEM_Y, ATTR_ROW(0),
  682.                PANEL_NOTIFY_PROC, do_restore_seg,
  683.                0);
  684.  
  685.   /* copy button */
  686.   but_copy_seg=panel_create_item(seg_panel, PANEL_BUTTON,
  687.                PANEL_LABEL_IMAGE, panel_button_image(seg_panel,
  688.            "Copy",
  689.                4,0),
  690.                PANEL_ITEM_X, ATTR_COL(34),
  691.                PANEL_ITEM_Y, ATTR_ROW(0),
  692.                PANEL_NOTIFY_PROC, do_copy_segment,
  693.                0);
  694.  
  695.   /* move button */
  696.   but_pos=panel_create_item(seg_panel, PANEL_BUTTON,
  697.                PANEL_LABEL_IMAGE, panel_button_image(seg_panel,
  698.                "Move",
  699.                4,0),
  700.                PANEL_ITEM_X, ATTR_COL(0),
  701.                PANEL_ITEM_Y, ATTR_ROW(1),
  702.                PANEL_NOTIFY_PROC, do_pos,
  703.                0);
  704.  
  705.   /* rotate button */
  706.   but_rot=panel_create_item(seg_panel, PANEL_BUTTON,
  707.                PANEL_LABEL_IMAGE, panel_button_image(seg_panel,
  708.                "Rotate",
  709.                6,0),
  710.                PANEL_ITEM_X, ATTR_COL(6),
  711.                PANEL_ITEM_Y, ATTR_ROW(1),
  712.                PANEL_NOTIFY_PROC, do_rot,
  713.                0);
  714.  
  715.   /* scale button */
  716.   but_size=panel_create_item(seg_panel, PANEL_BUTTON,
  717.                PANEL_LABEL_IMAGE, panel_button_image(seg_panel,
  718.                "Scale",
  719.                5,0),
  720.                PANEL_ITEM_X, ATTR_COL(14),
  721.                PANEL_ITEM_Y, ATTR_ROW(1),
  722.                PANEL_NOTIFY_PROC, do_size,
  723.                0);
  724.  
  725.   /* join button */
  726.   but_join=panel_create_item(seg_panel, PANEL_BUTTON,
  727.                PANEL_LABEL_IMAGE, panel_button_image(seg_panel,
  728.                "Join",
  729.                4,0),
  730.                PANEL_ITEM_X, ATTR_COL(21),
  731.                PANEL_ITEM_Y, ATTR_ROW(1),
  732.                PANEL_NOTIFY_PROC, do_join,
  733.                0);
  734.  
  735.   /* break button */
  736.   but_break=panel_create_item(seg_panel, PANEL_BUTTON,
  737.                PANEL_LABEL_IMAGE, panel_button_image(seg_panel,
  738.                "Break",
  739.                5,0),
  740.                PANEL_ITEM_X, ATTR_COL(27),
  741.                PANEL_ITEM_Y, ATTR_ROW(1),
  742.                PANEL_NOTIFY_PROC, do_break,
  743.                0);
  744.  
  745.   /* undelete button */
  746.   but_undelete=panel_create_item(seg_panel, PANEL_BUTTON,
  747.                PANEL_LABEL_IMAGE, panel_button_image(seg_panel,
  748.                "Undelete",
  749.                4,0),
  750.                PANEL_ITEM_X, ATTR_COL(34),
  751.                PANEL_ITEM_Y, ATTR_ROW(1),
  752.                PANEL_NOTIFY_PROC, do_undelete,
  753.                0);
  754.  
  755.   window_fit(seg_panel);
  756.  
  757.   /* create the primitive panel */
  758.   draw_panel=window_create(frame, PANEL,
  759.                WIN_BELOW, seg_panel,
  760.                WIN_X, ATTR_COLS(0),
  761.                0);
  762.  
  763.   /* polyline button */
  764.   but_polyline=panel_create_item(draw_panel, PANEL_BUTTON,
  765.                PANEL_LABEL_IMAGE, &polyline_pr,
  766.                PANEL_NOTIFY_PROC, do_polyline,
  767.                PANEL_ITEM_X, ATTR_COL(0),
  768.                PANEL_ITEM_Y, ATTR_ROW(0),
  769.                0);
  770.  
  771.   /* polygon button */
  772.   but_polygon=panel_create_item(draw_panel, PANEL_BUTTON,
  773.                PANEL_LABEL_IMAGE, &polygon_pr,
  774.                PANEL_ITEM_X, ATTR_COL(4),
  775.                PANEL_ITEM_Y, ATTR_ROW(0),
  776.                PANEL_NOTIFY_PROC, do_polygon,
  777.                0);
  778.  
  779.   /* circle button */
  780.   but_circle=panel_create_item(draw_panel, PANEL_BUTTON,
  781.                PANEL_LABEL_IMAGE, &circle_pr,
  782.                PANEL_ITEM_X, ATTR_COL(8),
  783.                PANEL_ITEM_Y, ATTR_ROW(0),
  784.                PANEL_NOTIFY_PROC, do_circle,
  785.                0);
  786.  
  787.   /* rectangle button */
  788.   but_rect=panel_create_item(draw_panel, PANEL_BUTTON,
  789.                PANEL_LABEL_IMAGE, &rect_pr,
  790.                PANEL_ITEM_X, ATTR_COL(12),
  791.                PANEL_ITEM_Y, ATTR_ROW(0),
  792.                PANEL_NOTIFY_PROC, do_rect,
  793.                0);
  794.  
  795.   /* trace button */
  796.   but_trace=panel_create_item(draw_panel, PANEL_BUTTON,
  797.                PANEL_LABEL_IMAGE, &trace_pr,
  798.                PANEL_ITEM_X, ATTR_COL(16),
  799.                PANEL_ITEM_Y, ATTR_ROW(0),
  800.                PANEL_NOTIFY_PROC, do_trace,
  801.                0);
  802.  
  803.   /* ellipse button */
  804.   but_ellipse=panel_create_item(draw_panel, PANEL_BUTTON,
  805.                PANEL_LABEL_IMAGE, &ellipse_pr,
  806.                PANEL_NOTIFY_PROC, do_ellipse,
  807.                PANEL_ITEM_X, ATTR_COL(20),
  808.                PANEL_ITEM_Y, ATTR_ROW(0),
  809.                0);
  810.  
  811.   /* arc button */
  812.   but_arc=panel_create_item(draw_panel, PANEL_BUTTON,
  813.                PANEL_LABEL_IMAGE, &arc_pr,
  814.                PANEL_NOTIFY_PROC, do_arc,
  815.                PANEL_ITEM_X, ATTR_COL(24),
  816.                PANEL_ITEM_Y, ATTR_ROW(0),
  817.                0);
  818.  
  819.   /* text button */
  820.   but_text=panel_create_item(draw_panel, PANEL_BUTTON,
  821.                PANEL_LABEL_IMAGE, &text_pr,
  822.                PANEL_NOTIFY_PROC, do_text,
  823.                PANEL_ITEM_X, ATTR_COL(0),
  824.                PANEL_ITEM_Y, ATTR_ROW(0)+20,
  825.                0);
  826.  
  827.   /* text field */
  828.   text_textstr=panel_create_item(draw_panel, PANEL_TEXT,
  829.                  PANEL_LABEL_STRING, ":",
  830.                  PANEL_VALUE_DISPLAY_LENGTH, 30,
  831.                  PANEL_ITEM_Y, ATTR_ROW(0)+20,
  832.                  PANEL_ITEM_X, ATTR_COL(3),
  833.                  0);
  834.  
  835.   window_fit(draw_panel);
  836.  
  837.   /* create the attribute panel */
  838.   attr_panel=window_create(frame, PANEL,
  839.                WIN_BELOW, draw_panel,
  840.                WIN_X, ATTR_COLS(0),
  841.                0);
  842.  
  843.   /* line width slider */
  844.   slider_linewidth=panel_create_item(attr_panel, PANEL_SLIDER,
  845.                PANEL_LABEL_STRING, "Line width:",
  846.                PANEL_VALUE, 0,
  847.                PANEL_MIN_VALUE, 0,
  848.                PANEL_MAX_VALUE, 99,
  849.                PANEL_SHOW_VALUE, TRUE,
  850.                PANEL_SLIDER_WIDTH, ATTR_COLS(15),
  851.                PANEL_ITEM_X, ATTR_COL(0),
  852.                PANEL_ITEM_Y, ATTR_ROW(0),
  853.                PANEL_NOTIFY_PROC, do_change_linewidth,
  854.                0);
  855.  
  856.   /* slider for grid interval along x axis */
  857.   slider_gridx=panel_create_item(attr_panel, PANEL_SLIDER,
  858.                PANEL_LABEL_STRING, "Grid interval: x",
  859.                PANEL_VALUE, (int) GE_DEFAULT_GRID,
  860.                PANEL_MIN_VALUE, (int) GE_MIN_GRID,
  861.                PANEL_MAX_VALUE, (int) (GE_WIN_X/10),
  862.                PANEL_SLIDER_WIDTH, ATTR_COLS(15),
  863.                PANEL_ITEM_X, ATTR_COL(0),
  864.                PANEL_ITEM_Y, ATTR_ROW(1),
  865.                PANEL_NOTIFY_PROC, do_change_grid,
  866.                0);
  867.  
  868.   /* slider for grid interval along y axis */
  869.   slider_gridy=panel_create_item(attr_panel, PANEL_SLIDER,
  870.                PANEL_LABEL_STRING, "               y",
  871.                PANEL_VALUE, (int) GE_DEFAULT_GRID,
  872.                PANEL_MIN_VALUE, (int) GE_MIN_GRID,
  873.                PANEL_MAX_VALUE, (int) (GE_WIN_Y/10),
  874.                PANEL_SLIDER_WIDTH, ATTR_COLS(15),
  875.                PANEL_ITEM_X, ATTR_COL(0),
  876.                PANEL_ITEM_Y, ATTR_ROW(2),
  877.                PANEL_NOTIFY_PROC, do_change_grid,
  878.                0);
  879.  
  880.   /* color slider */
  881.   slider_color=panel_create_item(attr_panel, PANEL_SLIDER,
  882.                PANEL_LABEL_STRING, "Color:",
  883.                PANEL_ITEM_X, ATTR_COL(0),
  884.                PANEL_ITEM_Y, ATTR_ROW(3),
  885.                PANEL_VALUE, 0,
  886.                PANEL_MIN_VALUE, 0,
  887.                PANEL_MAX_VALUE, 11,
  888.                PANEL_SLIDER_WIDTH, ATTR_COLS(15),
  889.                PANEL_NOTIFY_PROC, do_change_color,
  890.                0);
  891.  
  892.   /* character size slider */
  893.   slider_charsize=panel_create_item(attr_panel, PANEL_SLIDER,
  894.                PANEL_LABEL_STRING, "Font size:",
  895.                PANEL_VALUE, (int) GE_DEFAULT_CHARSIZE,
  896.                PANEL_MIN_VALUE, 1,
  897.                PANEL_MAX_VALUE, (int) 20,
  898.                PANEL_SLIDER_WIDTH, ATTR_COLS(15),
  899.                PANEL_ITEM_X, ATTR_COL(0),
  900.                PANEL_ITEM_Y, ATTR_ROW(4),
  901.                PANEL_NOTIFY_PROC, do_change_charsize,
  902.                0);
  903.  
  904.   /* line style menu */
  905.   menu_linestyle=panel_create_item(attr_panel, PANEL_CHOICE,
  906.                    PANEL_LABEL_STRING, "Line Style :",
  907.                    PANEL_FEEDBACK, PANEL_MARKED,
  908.                    PANEL_ITEM_X, ATTR_COL(0),
  909.                    PANEL_ITEM_Y, ATTR_ROW(5),
  910.                    PANEL_CHOICE_IMAGES, &solid_pr, &dot_pr,
  911.                                         &dash_pr, &dotdash_pr, 0,
  912.                    PANEL_CHOICE_XS,
  913.                      ATTR_COL(4),ATTR_COL(4),ATTR_COL(4),ATTR_COL(4),0,
  914.                    PANEL_CHOICE_YS,
  915.                      ATTR_ROW(7),ATTR_ROW(8),ATTR_ROW(9),ATTR_ROW(10),0,
  916.                    PANEL_MARK_XS,
  917.                      ATTR_COL(0),ATTR_COL(0),ATTR_COL(0),ATTR_COL(0),0,
  918.                    PANEL_MARK_YS,
  919.                      ATTR_ROW(7),ATTR_ROW(8),ATTR_ROW(9),ATTR_ROW(10),0,
  920.                    PANEL_NOTIFY_PROC, do_change_linestyle,
  921.                    0);
  922.  
  923.   /* font menu */
  924.   menu_font=panel_create_item(attr_panel, PANEL_CHOICE,
  925.                    PANEL_LABEL_STRING, "Font :",
  926.                    PANEL_FEEDBACK, PANEL_MARKED,
  927.                    PANEL_ITEM_X, ATTR_COL(16),
  928.                    PANEL_ITEM_Y, ATTR_ROW(5),
  929.                    PANEL_CHOICE_STRINGS, "Courier", "Roman", "Greek",
  930.                                          "BoldItalic", "Bold",0,
  931.                    PANEL_CHOICE_XS,
  932.                      ATTR_COL(20),ATTR_COL(20),ATTR_COL(20),
  933.                      ATTR_COL(20),ATTR_COL(20),0,
  934.                    PANEL_CHOICE_YS,
  935.                      ATTR_ROW(7),ATTR_ROW(8),ATTR_ROW(9),
  936.                      ATTR_ROW(10),ATTR_ROW(11),0,
  937.                    PANEL_MARK_XS,
  938.                      ATTR_COL(16),ATTR_COL(16),ATTR_COL(16),
  939.                      ATTR_COL(16),ATTR_COL(16),0,
  940.                    PANEL_MARK_YS,
  941.                      ATTR_ROW(7),ATTR_ROW(8),ATTR_ROW(9),
  942.                      ATTR_ROW(10),ATTR_ROW(11),0,
  943.                    PANEL_NOTIFY_PROC, do_change_font,
  944.                    0);
  945.  
  946.   /* grid on/off option */
  947.   cycle_grid=panel_create_item(attr_panel, PANEL_CYCLE,
  948.                PANEL_LABEL_STRING, "Grid ",
  949.                PANEL_ITEM_X, ATTR_COL(30),
  950.                PANEL_ITEM_Y, ATTR_ROW(5),
  951.                PANEL_CHOICE_STRINGS, "Off", "On", 0,
  952.                PANEL_NOTIFY_PROC, do_grid,
  953.                0);
  954.  
  955.   /* align on/off option */
  956.   cycle_align=panel_create_item(attr_panel, PANEL_CYCLE,
  957.                PANEL_LABEL_STRING, "Align",
  958.                PANEL_ITEM_X, ATTR_COL(30),
  959.                PANEL_ITEM_Y, ATTR_ROW(6),
  960.                PANEL_CHOICE_STRINGS, "Off", "On", 0,
  961.                PANEL_NOTIFY_PROC, do_align,
  962.                0);
  963.  
  964.   /* show options/options done button */
  965.   cycle_save=panel_create_item(attr_panel, PANEL_CYCLE,
  966.                PANEL_ITEM_X, ATTR_COL(30),
  967.                PANEL_ITEM_Y, ATTR_ROW(8),
  968.                PANEL_CHOICE_IMAGES,
  969.                  panel_button_image(seg_panel, "Show Options", 12,0),
  970.                  panel_button_image(seg_panel, "Options Done", 12,0),
  971.                  0,
  972.                PANEL_FEEDBACK, PANEL_NONE,
  973.                PANEL_SHOW_MENU, 0,
  974.                PANEL_NOTIFY_PROC, do_show_save,
  975.                0);
  976.  
  977.   /* fill option */
  978.   cycle_fill=panel_create_item(attr_panel, PANEL_CYCLE,
  979.                PANEL_ITEM_X, ATTR_COL(30),
  980.                PANEL_ITEM_Y, ATTR_ROW(9),
  981.                PANEL_CHOICE_IMAGES, &border_pr, &fill_pr, &borderfill_pr, 0,
  982.                0);
  983.  
  984.   window_fit(attr_panel);
  985.  
  986.   /* fit panels in frame */
  987.   window_fit(frame);
  988.  
  989.   /* adjust the width of the panels to the maximum among them */
  990.   {
  991.     int i, width, maxwidth;
  992.  
  993.     /* determine the maximum width */
  994.     width=0;
  995.     maxwidth=0;
  996.     for ( i=0; i<5; i++ ) {
  997.       width = (int) window_get(panels[i], WIN_WIDTH);
  998.       if ( width > maxwidth ) maxwidth = width;
  999.     } /* for */
  1000.  
  1001.     /* set all of them to the maximum width */
  1002.     for ( i=0; i<5; i++ ) {
  1003.       (void) window_set(panels[i], WIN_WIDTH, maxwidth, 0);
  1004.     } /* for */
  1005.   }
  1006.  
  1007. } /* make control panel */
  1008.  
  1009. /*****************************************************************************
  1010.  
  1011.     do_message displays a message on the message panel.
  1012.  
  1013.   Input
  1014.     mesg - message to display
  1015.  
  1016. *****************************************************************************/
  1017.  
  1018. do_message(mesg)
  1019. char *mesg;
  1020. {
  1021.   panel_set(mesg_display,
  1022.     PANEL_LABEL_STRING, mesg,
  1023.     0);
  1024.  
  1025. } /* do_message */
  1026.  
  1027. /*****************************************************************************
  1028.  
  1029.     do_usage display the usage of the three mouse buttons on the message
  1030.   panel.
  1031.  
  1032.   Input
  1033.     mesg1 - message for left button
  1034.     mesg2 - message for middle button
  1035.     mesg3 - message for right button
  1036.  
  1037. *****************************************************************************/
  1038.  
  1039. do_usage(mesg1, mesg2, mesg3)
  1040. char *mesg1, *mesg2, *mesg3;
  1041. {
  1042.   static char usage[80];
  1043.  
  1044.   sprintf(usage, "L: %-11s M: %-11s R: %-11s", mesg1, mesg2, mesg3);
  1045.   panel_set(mesg_usage,
  1046.     PANEL_LABEL_STRING, usage,
  1047.     0);
  1048.  
  1049. } /* do_usage */
  1050.  
  1051. /*****************************************************************************
  1052.  
  1053.     do_show_save is the notify procedure for the show options/options done
  1054.   option.  It creates the options window if it does not exist and
  1055.   show/close the window according to the value.
  1056.  
  1057.   Input
  1058.     value - value of show options/options done option
  1059.  
  1060. *****************************************************************************/
  1061.  
  1062. static Frame save_frame=0;
  1063. void do_show_save(item, value, event)
  1064. Panel_item item;
  1065. int value;
  1066. Event *event;
  1067. {
  1068.   extern Frame base_frame;
  1069.  
  1070.   if ( ! save_frame ) {
  1071.     /* create the options window */
  1072.     save_frame = (Frame)make_save_panel(base_frame);
  1073.   }
  1074.   else {
  1075.     /* show/close options window according to value */
  1076.     window_set(save_frame,
  1077.       WIN_SHOW, value,
  1078.       0);
  1079.   } /* else */
  1080.  
  1081. } /* do_show_save */
  1082.  
  1083. /*****************************************************************************
  1084.  
  1085.     do_reset_save is the quit notify procedure for the options window.  It is
  1086.   called when the Done option is chosen from the frame menu of the window.
  1087.   It will reset the value of the show options/options done option and
  1088.   actually close the window.
  1089.  
  1090. *****************************************************************************/
  1091.  
  1092. void do_reset_save()
  1093. {
  1094.   panel_set(cycle_save,
  1095.     PANEL_VALUE, 0,
  1096.     0);
  1097.  
  1098.   /* close the window */
  1099.   window_set(save_frame,
  1100.     WIN_SHOW, 0,
  1101.     0);
  1102.  
  1103. } /* do_reset_save */
  1104. @//E*O*F panel.c//
  1105. chmod u=r,g=r,o=r panel.c
  1106.  
  1107. echo x - savepanel.c
  1108. sed 's/^@//' > "savepanel.c" <<'@//E*O*F savepanel.c//'
  1109.  
  1110. static char SccsId[] = "@(#)savepanel.c    1.1 6/8/87 Copyright 1987 SBCS-chan";
  1111.  
  1112. /*****************************************************************************
  1113.  
  1114.           (c) Copyright 1987 
  1115.  
  1116.           Lap-Tak Chan
  1117.           Computer Science Department
  1118.           State University of New York at Stony Brook
  1119.           Stony Brook, NY 11794
  1120.  
  1121.     This software and its documentation may be used, copied, and
  1122.   distributed, provided that this legend appear in all copies and
  1123.   that it is not copied or distributed for a profit.
  1124.  
  1125.   No representations is made about the suitability of this software
  1126.   for any purpose.  It is provided "as is" with no support and no
  1127.   express or implied warranty.
  1128.  
  1129. *****************************************************************************/
  1130.  
  1131. /*****************************************************************************
  1132.  
  1133.                          Options Window
  1134.                          ==============
  1135.  
  1136.     This file contains routines for the options window.
  1137.  
  1138. *****************************************************************************/
  1139.  
  1140. #include <suntool/sunview.h>
  1141. #include <suntool/panel.h>
  1142. #include "display.h"
  1143.  
  1144. /* define how the diagram is placed on 8.5 x 11 paper */
  1145. extern struct saveattr save_attr;
  1146.  
  1147. static Panel_item cycle_fix, cycle_rotate, cycle_center, 
  1148.        slider_width, slider_height, slider_offa, slider_offb;
  1149.  
  1150. /* externally accessible panel items */
  1151. Panel_item cycle_scale, cycle_blink, cycle_optm, cycle_output, cycle_newseg,
  1152.            cycle_cont, cycle_raster;
  1153.  
  1154. extern void do_change_save(), do_reset_save(), do_set_timer();
  1155.  
  1156. /* raster images */
  1157. static short norotate_pr_image[]={
  1158. #include "images/norotate.pr"
  1159. };
  1160.  
  1161. static short rotate_pr_image[]={
  1162. #include "images/rotate.pr"
  1163. };
  1164.  
  1165. mpr_static(norotate_pr, 64, 64, 1, norotate_pr_image);
  1166. mpr_static(rotate_pr, 64, 64, 1, rotate_pr_image);
  1167.  
  1168. /*****************************************************************************
  1169.  
  1170.     make_save_panel will create a new frame for the option window and create
  1171.   a save panel and an option panel.
  1172.  
  1173.   Input
  1174.     frame - parent frame
  1175.  
  1176.   Output
  1177.     Return frame created.
  1178.  
  1179. *****************************************************************************/
  1180.  
  1181. Frame
  1182. make_save_panel(frame)
  1183. Frame frame;
  1184. {
  1185.  
  1186.   Frame newframe;
  1187.   Panel panels[2];
  1188. #define save_panel    panels[0]
  1189. #define option_panel    panels[1]
  1190.  
  1191.   /* create a new frame under parent frame */
  1192.   newframe=window_create(frame, FRAME,
  1193.                          WIN_SHOW,TRUE,
  1194.                          FRAME_DONE_PROC, do_reset_save,
  1195.                          0);
  1196.  
  1197.   /* create save panel */
  1198.   save_panel=window_create(newframe, PANEL,
  1199.                0);
  1200.  
  1201.   /* slider for w */
  1202.   slider_width=panel_create_item(save_panel, PANEL_SLIDER,
  1203.              PANEL_LABEL_STRING, "w",
  1204.              PANEL_VALUE, save_attr.width,
  1205.              PANEL_MIN_VALUE, 10,
  1206.              PANEL_MAX_VALUE, 75,
  1207.              PANEL_SLIDER_WIDTH, ATTR_COLS(15),
  1208.              PANEL_ITEM_X, ATTR_COL(0),
  1209.              PANEL_ITEM_Y, ATTR_ROW(0),
  1210.              PANEL_NOTIFY_PROC, do_change_save,
  1211.              0);
  1212.  
  1213.   /* slider for h */
  1214.   slider_height=panel_create_item(save_panel, PANEL_SLIDER,
  1215.              PANEL_LABEL_STRING, "h",
  1216.              PANEL_VALUE, save_attr.height,
  1217.              PANEL_MIN_VALUE, 10,
  1218.              PANEL_MAX_VALUE, 100,
  1219.              PANEL_SLIDER_WIDTH, ATTR_COLS(15),
  1220.              PANEL_ITEM_X, ATTR_COL(0),
  1221.              PANEL_ITEM_Y, ATTR_ROW(1),
  1222.              PANEL_NOTIFY_PROC, do_change_save,
  1223.              0);
  1224.  
  1225.   /* slider for a */
  1226.   slider_offa=panel_create_item(save_panel, PANEL_SLIDER,
  1227.              PANEL_LABEL_STRING, "a",
  1228.              PANEL_VALUE, save_attr.offa,
  1229.              PANEL_MIN_VALUE, 5,
  1230.              PANEL_MAX_VALUE, 85-save_attr.width,
  1231.              PANEL_SLIDER_WIDTH, ATTR_COLS(15),
  1232.              PANEL_ITEM_X, ATTR_COL(0),
  1233.              PANEL_ITEM_Y, ATTR_ROW(2),
  1234.              PANEL_NOTIFY_PROC, do_change_save,
  1235.              PANEL_SHOW_ITEM, ! save_attr.center,
  1236.              0);
  1237.  
  1238.   /* slider for b */
  1239.   slider_offb=panel_create_item(save_panel, PANEL_SLIDER,
  1240.              PANEL_LABEL_STRING, "b",
  1241.              PANEL_VALUE, save_attr.offb,
  1242.              PANEL_MIN_VALUE, 5,
  1243.              PANEL_MAX_VALUE, 110-save_attr.height,
  1244.              PANEL_SLIDER_WIDTH, ATTR_COLS(15),
  1245.              PANEL_ITEM_X, ATTR_COL(0),
  1246.              PANEL_ITEM_Y, ATTR_ROW(3),
  1247.              PANEL_NOTIFY_PROC, do_change_save,
  1248.              PANEL_SHOW_ITEM, ! save_attr.center,
  1249.              0);
  1250.  
  1251.   /* just a message on the panel */
  1252.   (void)panel_create_item(save_panel, PANEL_MESSAGE,
  1253.              PANEL_LABEL_STRING, "Lengths in 1/10\"",
  1254.              PANEL_ITEM_X, ATTR_COL(0),
  1255.              PANEL_ITEM_Y, ATTR_ROW(4),
  1256.              0);
  1257.  
  1258.   /* scale/fix width/fix height option */
  1259.   cycle_fix=panel_create_item(save_panel, PANEL_CYCLE,
  1260.              PANEL_VALUE, save_attr.fix,
  1261.              PANEL_ITEM_X, ATTR_COL(0),
  1262.              PANEL_ITEM_Y, ATTR_ROW(6),
  1263.              PANEL_CHOICE_STRINGS, "Scale", "Fix Width", "Fix Height", 0,
  1264.              PANEL_NOTIFY_PROC, do_change_save,
  1265.              0);
  1266.  
  1267.   /* center/offset option */
  1268.   cycle_center=panel_create_item(save_panel, PANEL_CYCLE,
  1269.              PANEL_VALUE, save_attr.center,
  1270.              PANEL_ITEM_X, ATTR_COL(0),
  1271.              PANEL_ITEM_Y, ATTR_ROW(7),
  1272.              PANEL_CHOICE_STRINGS, "Offset a,b", "Center", 0,
  1273.              PANEL_NOTIFY_PROC, do_change_save,
  1274.              0);
  1275.  
  1276.   /* rotate option */
  1277.   cycle_rotate=panel_create_item(save_panel, PANEL_CYCLE,
  1278.              PANEL_VALUE, save_attr.rotate,
  1279.              PANEL_ITEM_X, ATTR_COL(16),
  1280.              PANEL_ITEM_Y, ATTR_ROW(4),
  1281.              PANEL_CHOICE_IMAGES, &norotate_pr, &rotate_pr, 0,
  1282.              PANEL_NOTIFY_PROC, do_change_save,
  1283.              0);
  1284.  
  1285.   window_fit(save_panel);
  1286.  
  1287.   /* create option panel */
  1288.   option_panel=window_create(newframe, PANEL,
  1289.                WIN_BELOW, save_panel,
  1290.                WIN_X, ATTR_COLS(0),
  1291.                0);
  1292.  
  1293.   /* auto create option */
  1294.   cycle_newseg=panel_create_item(option_panel, PANEL_CYCLE,
  1295.                PANEL_LABEL_STRING, "Auto Create           ",
  1296.                PANEL_ITEM_X, ATTR_COL(0),
  1297.                PANEL_ITEM_Y, ATTR_ROW(0),
  1298.                PANEL_CHOICE_STRINGS, "Off", "On", 0,
  1299.                0);
  1300.  
  1301.   /* continous option */
  1302.   cycle_cont=panel_create_item(option_panel, PANEL_CYCLE,
  1303.              PANEL_LABEL_STRING, "Continous             ",
  1304.              PANEL_ITEM_X, ATTR_COL(0),
  1305.              PANEL_ITEM_Y, ATTR_ROW(1),
  1306.              PANEL_CHOICE_STRINGS, "No", "Yes", 0,
  1307.              0);
  1308.  
  1309.   /* proportional scale option */
  1310.   cycle_scale=panel_create_item(option_panel, PANEL_CYCLE,
  1311.              PANEL_LABEL_STRING, "Proportional Scale    ",
  1312.              PANEL_ITEM_X, ATTR_COL(0),
  1313.              PANEL_ITEM_Y, ATTR_ROW(2),
  1314.              PANEL_CHOICE_STRINGS, "No", "Yes", 0,
  1315.              0);
  1316.  
  1317.   /* blink current segment option */
  1318.   cycle_blink=panel_create_item(option_panel, PANEL_CYCLE,
  1319.              PANEL_LABEL_STRING, "Blink Current Segment ",
  1320.              PANEL_VALUE, 1,
  1321.              PANEL_ITEM_X, ATTR_COL(0),
  1322.              PANEL_ITEM_Y, ATTR_ROW(3),
  1323.              PANEL_CHOICE_STRINGS, "No", "Yes", 0,
  1324.              PANEL_NOTIFY_PROC, do_set_timer,
  1325.              0);
  1326.  
  1327.   /* optimize option */
  1328.   cycle_optm=panel_create_item(option_panel, PANEL_CYCLE,
  1329.              PANEL_LABEL_STRING, "Optimize before Save  ",
  1330.              PANEL_VALUE,1,
  1331.              PANEL_ITEM_X, ATTR_COL(0),
  1332.              PANEL_ITEM_Y, ATTR_ROW(4),
  1333.              PANEL_CHOICE_STRINGS, "No", "Yes", 0,
  1334.              0);
  1335.  
  1336.   /* output format option */
  1337.   cycle_output=panel_create_item(option_panel, PANEL_CYCLE,
  1338.              PANEL_LABEL_STRING, "Output Format         ",
  1339.              PANEL_ITEM_X, ATTR_COL(0),
  1340.              PANEL_ITEM_Y, ATTR_ROW(5),
  1341.              PANEL_CHOICE_STRINGS, "Raster", "Pic", "Plot", 0,
  1342.              0);
  1343.  
  1344.   /* select raster area option */
  1345.   cycle_raster=panel_create_item(option_panel, PANEL_CYCLE,
  1346.              PANEL_LABEL_STRING, "Select Area for Raster",
  1347.              PANEL_ITEM_X, ATTR_COL(0),
  1348.              PANEL_ITEM_Y, ATTR_ROW(6),
  1349.              PANEL_CHOICE_STRINGS, "No", "Yes", 0,
  1350.              0);
  1351.  
  1352.   window_fit(option_panel);
  1353.   window_fit(newframe);
  1354.  
  1355.   /* adjust both panels to the width of the wider panel */
  1356.   {
  1357.     int i, width, maxwidth;
  1358.  
  1359.     /* determine the maximum width */
  1360.     width=0;
  1361.     maxwidth=0;
  1362.     for ( i=0; i<2; i++ ) {
  1363.       width = (int) window_get(panels[i], WIN_WIDTH);
  1364.       if ( width > maxwidth ) maxwidth = width;
  1365.     } /* for */
  1366.  
  1367.     /* set both panels to the maximum */
  1368.     for ( i=0; i<2; i++ ) {
  1369.       (void) window_set(panels[i], WIN_WIDTH, maxwidth, 0);
  1370.     } /* for */
  1371.   }
  1372.  
  1373.   return(newframe);
  1374.  
  1375. } /* make_save_panel */
  1376.  
  1377. /*****************************************************************************
  1378.  
  1379.     do_change_save is the notify procedure of all the options on the save
  1380.   panel.  It updates the corresponding value in save_attr and change
  1381.   the setting of other options accordingly.
  1382.  
  1383.   Input
  1384.     item - panel item changed
  1385.     value - new value of panel item
  1386.  
  1387. *****************************************************************************/
  1388.  
  1389. void
  1390. do_change_save(item, value, event)
  1391. Panel_item item;
  1392. int value;
  1393. Event *event;
  1394. {
  1395.   if ( item == cycle_fix ) {
  1396.     /* scale/fix width/fix height option */
  1397.     save_attr.fix = value;
  1398.  
  1399.     /* disable slider for h when fix width */
  1400.     panel_set(slider_width,
  1401.       PANEL_SHOW_ITEM, ( (value == 0) || (value == 1) ),
  1402.       0);
  1403.  
  1404.     /* disable slider for w when fix height */
  1405.     panel_set(slider_height,
  1406.       PANEL_SHOW_ITEM, ( (value == 0) || (value == 2) ),
  1407.       0);
  1408.   }
  1409.  
  1410.   if ( item == cycle_rotate )
  1411.     /* rotate option */
  1412.     save_attr.rotate = value;
  1413.  
  1414.   if ( item == cycle_center ) {
  1415.     /* center/offset option */
  1416.     save_attr.center = value;
  1417.  
  1418.     /* disable slider for a and b when center */
  1419.     panel_set(slider_offa,
  1420.       PANEL_SHOW_ITEM, ! value,
  1421.       0);
  1422.     panel_set(slider_offb,
  1423.       PANEL_SHOW_ITEM, ! value,
  1424.       0);
  1425.   }
  1426.  
  1427.   if ( item == slider_width ) {
  1428.     int maxoffa;
  1429.  
  1430.     save_attr.width = value;
  1431.     /* adjust maximum offset a */
  1432.     maxoffa=85-value;
  1433.     panel_set(slider_offa,
  1434.               PANEL_MAX_VALUE, maxoffa,
  1435.               0);
  1436.  
  1437.     /* reduce offset a if it is larger than maximum */
  1438.     if ( save_attr.offa > maxoffa ) {
  1439.       panel_set(slider_offa,
  1440.                 PANEL_VALUE, maxoffa,
  1441.                 0);
  1442.       save_attr.offa = maxoffa;
  1443.     }
  1444.   }
  1445.  
  1446.   if ( item == slider_height ) {
  1447.     int maxoffb;
  1448.  
  1449.     save_attr.height = value;
  1450.  
  1451.     /* adjust maximum offset b */
  1452.     maxoffb=110-value;
  1453.     panel_set(slider_offb,
  1454.               PANEL_MAX_VALUE, maxoffb,
  1455.               0);
  1456.  
  1457.     /* reduce offset b when larger than maximum */
  1458.     if ( save_attr.offb > maxoffb ) {
  1459.       panel_set(slider_offb,
  1460.                 PANEL_VALUE, maxoffb,
  1461.                 0);
  1462.       save_attr.offb = maxoffb;
  1463.     }
  1464.   }
  1465.  
  1466.   if ( item == slider_offa )
  1467.     save_attr.offa = value;
  1468.  
  1469.   if ( item == slider_offb )
  1470.     save_attr.offb = value;
  1471.  
  1472. } /* do_change_save */
  1473. @//E*O*F savepanel.c//
  1474. chmod u=r,g=r,o=r savepanel.c
  1475.  
  1476. echo Inspecting for damage in transit...
  1477. temp=/tmp/shar$$; dtemp=/tmp/.shar$$
  1478. trap "rm -f $temp $dtemp; exit" 0 1 2 3 15
  1479. cat > $temp <<\!!!
  1480.       80     463    3462 README
  1481.       89     353    2663 Makefile
  1482.      126     695    4492 display.h
  1483.      745    1672   24557 panel.c
  1484.      364     955   10974 savepanel.c
  1485.     1404    4138   46148 total
  1486. !!!
  1487. wc  README Makefile display.h panel.c savepanel.c | sed 's=[^ ]*/==' | diff -b $temp - >$dtemp
  1488. if [ -s $dtemp ]
  1489. then echo "Ouch [diff of wc output]:" ; cat $dtemp
  1490. else echo "No problems found."
  1491. fi
  1492. exit 0
  1493.  
  1494.  
  1495.  
  1496.  
  1497.